﻿<UserControl x:Class="Mido.UiModules.ActiveImageModule.ActiveImageView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Controls="clr-namespace:Mido.Controls"
             xmlns:ActiveImageModule="clr-namespace:Mido.UiModules.ActiveImageModule"
             xmlns:Properties="clr-namespace:Mido.Properties" mc:Ignorable="d" d:DataContext="{x:Static ActiveImageModule:ActiveImageViewModel.Designer}"
             d:DesignHeight="500" d:DesignWidth="500">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Controls:WatermarkedImage Grid.ZIndex="0" Image="{Binding ActiveImage}" Settings="{Binding Settings}" Loaded="Image_Loaded" DataContextChanged="Image_DataContextChanged" SourceUpdated="Image_SourceUpdated" TargetUpdated="Image_TargetUpdated" 
                                       RenderOptions.BitmapScalingMode="HighQuality"/>

            <StackPanel VerticalAlignment="Top" HorizontalAlignment="Right" Orientation="Horizontal" Visibility="{Binding ImageCommandsPanelVisibility}" Grid.ZIndex="1">
                <Button Command="{Binding RotateLeftCommand}" RenderTransformOrigin="0.5, 0.5" Height="20" Width="20" Margin="3" ToolTip="{x:Static Properties:Resources.ActiveImageView_Rotate_left}">
                    <Button.Template>
                        <ControlTemplate>
                            <Grid>
                                <Rectangle Fill="Transparent"/>
                                <Path Name="path" Opacity="0.3" Stroke="White" Stretch="Fill" Fill="Black" Data="M16.173,5.77c1.915,0,3.667,0.629,5.088,1.687l-1.779,1.783l8.428,2.256l-2.26-8.428L23.76,4.958  c-2.07-1.677-4.715-2.688-7.586-2.688C9.5,2.272,4.091,7.681,4.09,14.354c0.001,4.063,2.012,7.647,5.084,9.839v-4.887  c-0.993-1.4-1.583-3.105-1.585-4.959C7.596,9.614,11.432,5.777,16.173,5.77z M10.173,29.73h12V12.854h-12V29.73z"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="path" Property="Opacity" Value="1"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Button.Template>
                    <Button.RenderTransform>
                        <ScaleTransform ScaleX="-1"/>
                    </Button.RenderTransform>
                </Button>
                <Button Command="{Binding RotateRightCommand}" Height="20" Width="20" Margin="3" ToolTip="{x:Static Properties:Resources.ActiveImageView_Rotate_right}">
                    <Button.Template>
                        <ControlTemplate>
                            <Grid>
                                <Rectangle Fill="Transparent"/>
                                <Path Name="path" Stroke="White" Opacity="0.3" Stretch="Fill" Fill="Black" Data="M16.173,5.77c1.915,0,3.667,0.629,5.088,1.687l-1.779,1.783l8.428,2.256l-2.26-8.428L23.76,4.958  c-2.07-1.677-4.715-2.688-7.586-2.688C9.5,2.272,4.091,7.681,4.09,14.354c0.001,4.063,2.012,7.647,5.084,9.839v-4.887  c-0.993-1.4-1.583-3.105-1.585-4.959C7.596,9.614,11.432,5.777,16.173,5.77z M10.173,29.73h12V12.854h-12V29.73z"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="path" Property="Opacity" Value="1"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <Button Command="{Binding ClearCustomPositionCommand}" Visibility="{Binding ClearCustomPositionCommandVisibility}" Margin="3" Height="20" Width="20" ToolTip="{x:Static Properties:Resources.ActiveImageView_Remove_custom_position}">
                    <Button.Template>
                        <ControlTemplate>
                            <Grid>
                                <Rectangle Fill="Transparent"/>
                                <Path Name="path" Stretch="Fill" Stroke="White" Opacity="0.3" Fill="Black" Data="M24.584,16.001c-0.01,4.739-3.846,8.574-8.583,8.583c-4.741-0.009-8.577-3.844-8.585-8.583  C7.423,11.26,11.259,7.424,16,7.416c1.914,0,3.666,0.629,5.089,1.686l-1.781,1.783l8.428,2.256l-2.26-8.427l-1.889,1.89  C21.516,4.927,18.871,3.916,16,3.916C9.327,3.919,3.918,9.327,3.917,16.001C3.918,22.676,9.327,28.084,16,28.084  c6.673,0,12.083-5.408,12.083-12.083H24.584z"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="path" Property="Opacity" Value="1"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <Button Command="{Binding ExcludeCommand}" Height="20" Width="20" Margin="3" ToolTip="{x:Static Properties:Resources.ActiveImageView_Exclude}">
                    <Button.Template>
                        <ControlTemplate>
                            <Grid>
                                <Rectangle Fill="Transparent"/>
                                <Path Name="path" Stretch="Fill" Stroke="White" Opacity="0.3" Fill="Black" Data="M50,0C22.385,0,0,22.385,0,50s22.385,50,50,50s50-22.385,50-50S77.615,0,50,0z M79.95,68.718L68.406,80.262L49.688,61.543    L30.97,80.262L19.426,68.718L38.145,50L19.426,31.286L30.97,19.742l18.718,18.715l18.718-18.715L79.95,31.286L61.232,50    L79.95,68.718z"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="path" Property="Opacity" Value="1"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
            </StackPanel>
        </Grid>
        
        <Button Grid.Column="0" VerticalAlignment="Center" Width="30" Height="75" Command="{Binding ShowPrivCommand}" BorderThickness="0" Opacity="0.3" Visibility="{Binding PrevImageVisibility}">
            <Path Data="M0,0.5 L1,1 1,0Z" Width="10" Height="20" Stretch="Fill" Fill="Black" />
        </Button>
        <Button Grid.Column="2" VerticalAlignment="Center" Width="30" Height="75" Command="{Binding ShowNextCommand}" BorderThickness="0" Opacity="0.3" Visibility="{Binding NextImageVisibility}">
            <Path Data="M0,0 L1,0.5 0,1Z" Width="10" Height="20" Stretch="Fill" Fill="Black" />
        </Button>

    </Grid>
</UserControl>
